package main

import (
	"fmt"
	"shop/gorm_test/db"
	"shop/gorm_test/global"
	"shop/gorm_test/insert"
)

func main() {

	db.InitDb()
	//var o insert.Order
	//global.Db.Model(o).Create(map[string]interface{}{
	//	"OrderNo": "4444",
	//})
	var o insert.Order
	global.Db.Find(&o)

	fmt.Println(o.ID)
	global.Db.Create(&insert.Order{
		OrderNo: "555",
		Phone:   "0",
		UserId:  0,
	})
	//data := []insert.Order{}
	//u := insert.Order{
	//
	//	OrderNo:      "12321",
	//	UserId:       2,
	//	Phone:        "1876633",
	//	ActivityId:   333,
	//	ActivityName: "sess",
	//}
	//u1 := insert.Order{
	//	OrderNo:      "12321",
	//	UserId:       2,
	//	Phone:        "1876633",
	//	ActivityId:   333,
	//	ActivityName: "sess",
	//}
	//data = append(data, u)
	//data = append(data, u1)

	//var order = []insert.Order{
	//	{OrderNo: "12321",
	//		UserId:       2,
	//		Phone:        "1876633",
	//		ActivityId:   333,
	//		ActivityName: "sess",
	//	},
	//	{
	//		OrderNo:      "12321",
	//		UserId:       2,
	//		Phone:        "1876633",
	//		ActivityId:   333,
	//		ActivityName: "sess",
	//	},
	//}
	//global.Db.CreateInBatches(order, 10)

	//data := make([]interface{}, 0)
	u := insert.Order{}
	u.OrderNo = "12323"
	u.ActivityId = 1
	u.ActivityName = "test"
	u.Phone = "18768140840"

	u.InsertOne()
	//fmt.Println(r.OrderNo)
	//fmt.Println(u.ID)
	//data := []insert.Order{}
	//u = insert.Order{
	//
	//	OrderNo:      "12321",
	//	UserId:       2,
	//	Phone:        "1876633",
	//	ActivityId:   333,
	//	ActivityName: "sess",
	//}
	//u1 := insert.Order{
	//
	//	OrderNo:      "12321",
	//	UserId:       2,
	//	Phone:        "1876633",
	//	ActivityId:   333,
	//	ActivityName: "sess",
	//}
	//data = append(data, u)
	//data = append(data, u1)
	//
	//insert.InsertMore(data)

	////res := u.InsertMore()
	//
	//data = append(data, res.Error)
	//data = append(data, res.RowsAffected)
	//
	//fmt.Println(data)

	//global.Db.AutoMigrate(&insert.Order{})
}
